<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dict">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-select
            v-model="dataForm.merchantId"
            placeholder="请选择商家名称"
            clearable
          >
            <el-option
              v-for="item in merchantNameOption"
              :key="item.merchantId"
              :label="item.merchantName"
              :value="item.merchantId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="" @click="getDataList()">{{
            $t("query")
          }}</el-button>
        </el-form-item>
         <el-form-item>
                    <el-button v-if="$hasPermission('merchant:ismerchantwithdrawalcheckinfo:delete')" type="danger" @click="deleteHandle()">{{
                        $t("deleteBatch") }}</el-button>
                </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          prop="merchantName"
          label="商家名称"
          header-align="center"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="merchantType"
          label="商户类型"
          header-align="center"
          align="center"
          min-width="120"
        >
          <template slot-scope="scope">
            {{ $getDictLabel("MerchantType", scope.row.merchantType) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="amount"
          label="提现金额"
          header-align="center"
          align="center"
          width="180"
        ></el-table-column>
        <el-table-column
          prop="status"
          label="状态"
          header-align="center"
          align="center"
          width="180"
        >
          <template slot-scope="scope">
            {{ scope.row.checkStatus | delStatus }}
          </template>
        </el-table-column>
        <el-table-column
          prop="createDate"
          label="申请时间"
          header-align="center"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              v-if="
                scope.row.checkStatus == 0 && $hasPermission('merchant:info:audit')
              "
              type="text"
              size="small"
              @click="lookDetail(scope.row.id)"
              >审核</el-button
            >
             <el-button type="text" v-if="$hasPermission('merchant:ismerchantwithdrawalcheckinfo:delete')" size="small"
                            @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 详情审核 -->
      <look-detail
        v-if="lookDetailVisible"
        ref="lookDetail"
        @refreshDataList="getDataList"
      ></look-detail>
    </div>
  </el-card>
</template>

<script>
var that;
import mixinViewModule from "@/mixins/view-module";
import lookDetail from "./ismerchantwithdrawalcheckinfo-update";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "order/ismerchantwithdrawalcheckinfo/page",
        getDataListIsPage: true,
          deleteURL: "/order/ismerchantwithdrawalcheckinfo",
                deleteIsBatch: true,
      },
      merchantNameOption: [],
      status: [
        {
          label: "审核未通过",
          value: 2,
        },
        {
          label: "审核通过",
          value: 1,
        },
        {
          label: "待审核",
          value: 0,
        },
      ],
      dataForm: {
        merchantId: "",
      },
    };
  },
  created() {
    that = this;
    this.getmerchantNameOption();
  },
  filters: {
    delStatus(val) {
      if (val!==undefined) {
        let d = that.status.filter((item) => item.value == val);
        if (d.length != 0) {
          return d[0].label;
        }
      }
    },
  },
  components: {
    lookDetail,
  },
  methods: {
    getmerchantNameOption() {
      this.$http
        .post("/order/merchant/wallet/info/getMerchantInfoList", {
          merchantTypeList: [1, 2,3, 4, 10],
        })
        .then(({ data: res }) => {
          if (res.msg == "success") {
            this.merchantNameOption = res.data;
          }
        });
    },
  },
};
</script>
